export const routesInfo = [
  {
    id: 1,
    title: 'DashBoard',
    path: null,
    component: null,
    pid: 0,
    type: 'menu',
    priority: 1
  },
  {
    id: 2,
    title: '主页',
    path: '/home',
    component: '/HomeView.vue',
    pid: 1,
    type: 'route',
    priority: 1
  },
  {
    id: 3,
    title: '关于公司',
    path: '/about',
    component: '/AboutView.vue',
    pid: 1,
    type: 'route',
    priority: 2
  },
  {
    id: 4,
    title: '指针',
    path: '/point',
    component: '/PointRouter.vue',
    pid: 1,
    type: 'route',
    priority: 3
  },
  {
    id: 5,
    title: 'Others',
    path: null,
    component: null,
    pid: 0,
    type: 'menu',
    priority: 2
  },
  {
    id: 6,
    title: '练习1',
    path: '/prac1',
    component: '/Prac1View.vue',
    pid: 5,
    type: 'route',
    priority: 1
  },
  {
    id: 7,
    title: '物品单据',
    path: '/someBill',
    component: '/SomeBill.vue',
    pid: 1,
    type: 'route',
    priority: 1
  }
  ,
  {
    id: 8,
    title: '多条件查询',
    path: '/query',
    component: '/QueryView.vue',
    pid: 5,
    type: 'route',
    priority: 1
  }
]
export function geneForNav() {
  console.log(routesInfo)
  const info = JSON.parse(JSON.stringify(routesInfo))
  for (const route of info) {
    if (route.pid !== 0) {
      const parent = info.find((e:any) => e.id === route.pid)
      if (parent) {
        if (!parent.children) parent.children = []
        parent.children.push(route)
      }
    }
  }
  const r = info.filter((e:any) => e.children)
  console.log(r)
  return r
}
export function geneForRt() {
  const info = JSON.parse(JSON.stringify(routesInfo))
  const r = info.filter((x:any) => x.type === 'route')
  const rr = r.map((x:any) => {
    return {
      path: x.path,
      component: () => import('../views' + x.component)
    }
  });

  console.log("routes ",rr)
  return rr
}
